window.workspace = function(){
	var response  = <?#$respons?>;
	var store, grid, win;
	var sid = {'ver':Ext.id(), 'os':Ext.id(), 'msg':Ext.id(), 'device':Ext.id(),
		'sdate':Ext.id(), 'edate':Ext.id(), 'preview':Ext.id()};

	function openText(data){
		win && win.close();
		win = new Ext.Window({
			title	: '日志详情',
			iconCls	: 'icon-edit',	
			width	: 760,
			items   : [{html:data, id:sid.preview}],
			closeAction : 'hide'
		});
		win.show();
	};

	store = new Ext.data.JsonStore({
	    autoDestroy	: true,
	    url			: '/admin/live/log/appcrash/dolist.html',
	    remoteSort	: true,
	    sortInfo	: {
	            field		: 'id',
	            direction	: 'DESC'
		},
		baseParams	: {
			start	: 0,
			slot	: response.slot,
			limit	: main.pageSize
		},
		autoLoad		: true,
	    root			: 'dataset',
	 	totalProperty	: 'total',
	    fields			: ['id', 'userid', 'device', 'os', 'ver', 'msg', 'file', 'ip', 'stime']
	});
	
 	grid = {
		xtype		: 'grid',
		title		: response.title,
	    store		: store,
		region		: 'center', 
	    columns		: [
			{header: 'ID编号', width:60, sortable:true, dataIndex:'id'},
			{header: '账号[user]', width:60, dataIndex:'userid'},
			{header: '设备型号[device]', width:80, dataIndex:'device'},
			{header: 'OS版本[os]', width:60, dataIndex:'os'},
			{header: '应用版本[version]', width:60, dataIndex:'ver'},
			{header: '奔溃信息[msg]', width:260, dataIndex:'msg'},
			{header: '日志下载[file]', width:80, dataIndex:'file', renderer:function(v,obj,meta){
				var segs = (!v)? null:v.split(":");
				if (!segs || segs.length != 2) {
					return '';
				}
				var url  = 'http://'+segs[0]+':8080/stream/download?id='+meta.get('id');
				return '<a target="__blank" href="'+url+'">点击下载</a>';
			}},
			{header: '客户端IP[IP]', width:80, dataIndex:'ip'},
			{header: '记录时间[Addtime]', width:100, dataIndex:'stime'}
		],
	    viewConfig	: {
	        forceFit	 : true,
	        scrollOffset : 0
	    },
	    listeners	: {
			'destroy':function(){
    			win && win.close();
    		},
			'rowdblclick':function(obj, index, e){
				var data = obj.store.getAt(index).copy();
				openText(data.get('msg'));
			}
	    },
	    sm			: new Ext.grid.RowSelectionModel({singleSelect:true}),
	    stripeRows	: true,
	    tbar		: [{
			text	: 'Reload',
			iconCls	: 'icon-refresh',
			handler : function(){
				store.reload(); 
			}
	    },'-','<b>Search For：</b>','设备型号:',{
			xtype       : 'textfield',
			id	    	: sid.device,
			width	    : 80
		},'-','OS版本:',{
			xtype       : 'textfield',
			id	    	: sid.os,
			width	    : 80
		},'-','应用版本:',{
			xtype       : 'textfield',
			id	    	: sid.ver,
			width	    : 80
		},'-','奔溃信息:',{
			xtype       : 'textfield',
			id	    	: sid.msg,
			width	    : 160
		},'-','记录时间:',{
			xtype       : 'datefield',
			id  		: sid.sdate,
			width	    : 120
		},'<->',{
			xtype       : 'datefield',
			id  		: sid.edate,
			width	    : 120
		},'-',{
			text			: 'Do Search',
			iconCls			: 'icon-search',
			handler: function() {
				store.baseParams.device = Ext.getCmp(sid.device).getValue();
				store.baseParams.os     = Ext.getCmp(sid.os).getValue();
				store.baseParams.ver    = Ext.getCmp(sid.ver).getValue();
				store.baseParams.msg    = Ext.getCmp(sid.msg).getValue();
				store.baseParams.sdate  = Ext.getCmp(sid.sdate).getValue();
				store.baseParams.edate  = Ext.getCmp(sid.edate).getValue();
				store.reload(); 
			}
		}],
		bbar		: new Ext.PagingToolbar({
			pageSize	: main.pageSize,
			store		: store,
			displayInfo	: true
		})
	};
	return grid;
}();